package base;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Author: DRevelation
 * @Date: 2021/4/21 10:11
 */
public class ExecutorServiceDemo {

    private static final ExecutorService exec = Executors.newFixedThreadPool(2);

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            try {
                int finalI = i;
                exec.execute(() -> System.out.println("Thread-" + finalI));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

}
